package com.espirit.eap.sa;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import org.hibernate.annotations.Index;
import org.hibernate.annotations.Table;

import com.espirit.eap.ICheckModelDuplicateInfo;
import com.espirit.eap.annotation.Dict;
import com.espirit.eap.annotation.DomainModel;
import com.espirit.eap.annotation.ModelDisplayProperty;
import com.espirit.eap.manager.Department;
import com.espirit.finance.core.Flag;
import com.googlecode.cswish.annotation.QLFormula;
import com.googlecode.cswish.model.Saas;

@Entity
@DomainModel
@ModelDisplayProperty("name")
@Table(indexes={
		@Index(name="idx_dutycardnbr", columnNames={"dutycardnbr"} ),
		@Index(name="idx_userid", columnNames={"userid"} ),
		},appliesTo = "saas_employee")
public class Employee  implements Serializable, Flag, DepartmentAware, BasicScopeAware, ICheckModelDuplicateInfo, Saas{
	private static final long serialVersionUID = 6807029881373946573L;
	public static final String 	POSITION = "employee_position";
	public static final String EDUCATION = "employee_education";
	public static final String SEX = "sex";
	
	public static final String IDTYPE ="employee_idtype";
	public static final String SOCIALTYPE = "employee_socialtype" ;
	
	public static final String ATTRIBUTE = "employee_attribute";
	
	public static final Integer ATTRIBUTE_FIXED_SALARY = 1;
	public static final Integer ATTRIBUTE_HOUR_SALARY = 2;
	public static final Integer ATTRIBUTE_TEMPORY = 3;
	
	private Integer position; //dictionary : position
	
	private Department department;
	
	
	private Integer sid;
	public Integer getSid() {
		return sid;
	}

	public void setSid(Integer sid) {
		this.sid = sid;
	}
	
	private Integer id;
	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	@ManyToOne
	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	@Dict(type=POSITION)
	public Integer getPosition() {
		return position;
	}

	public void setPosition(Integer position) {
		this.position = position;
	}
	
	public Integer getFixedSalary() {
		return fixedSalary;
	}

	public void setFixedSalary(Integer fixedSalary) {
		this.fixedSalary = fixedSalary;
	}

	public Integer getMeritSalary() {
		return meritSalary;
	}

	public void setMeritSalary(Integer meritSalary) {
		this.meritSalary = meritSalary;
	}

	@Dict(type=ACTIVE)
	public Integer getActive() {
		return active;
	}

	public void setActive(Integer active) {
		this.active = active;
	}

	@Transient
	@QLFormula(value = "active", type = Integer.class)
	public String getActiveFlag() {
		if (this.active == null ){
			return ACTIVE_NO.toString();
		} 
		return this.active.toString();
	}
	public String getBankNbr() {
		return bankNbr;
	}

	public void setBankNbr(String bankNbr) {
		this.bankNbr = bankNbr;
	}
	
	@Transient
	public String getDeptIds() {
		return deptIds;
	}
	public void setDeptIds(String deptIds) {
		this.deptIds = deptIds;
	}
	
	@Dict(type=EDUCATION)
	public Integer getEducation() {
		return education;
	}

	public void setEducation(Integer education) {
		this.education = education;
	}


	@Dict(type=SEX)
	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}


	public String getIdCard() {
		return idCard;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}


	public String getIdCardAddress() {
		return idCardAddress;
	}

	public void setIdCardAddress(String idCardAddress) {
		this.idCardAddress = idCardAddress;
	}


	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}


	public BigDecimal getExchangeHours() {
		return exchangeHours;
	}

	public void setExchangeHours(BigDecimal exchangeHours) {
		this.exchangeHours = exchangeHours;
	}


	@Dict(type=IDTYPE)
	public Integer getIdType() {
		return idType;
	}

	public void setIdType(Integer idType) {
		this.idType = idType;
	}


	@Dict(type=SOCIALTYPE)
	public Integer getSocialType() {
		return socialType;
	}

	public void setSocialType(Integer socialType) {
		this.socialType = socialType;
	}
	
	
//	public String getWorkGroupIds() {
//		return workGroupIds;
//	}
//
//	public void setWorkGroupIds(String workGroupIds) {
//		this.workGroupIds = workGroupIds;
//	}


	public Integer getSubsidy() {
		return subsidy;
	}

	public void setSubsidy(Integer subsidy) {
		this.subsidy = subsidy;
	}

	public String getDutyCardNbr() {
		return dutyCardNbr;
	}

	public void setDutyCardNbr(String dutyCardNbr) {
		this.dutyCardNbr = dutyCardNbr;
	}


	@Dict(type=ATTRIBUTE)
	public Integer getAttribute() {
		return attribute;
	}

	public void setAttribute(Integer attribute) {
		this.attribute = attribute;
	}


	public BigDecimal getHourSalary() {
		return hourSalary;
	}

	public void setHourSalary(BigDecimal hourSalary) {
		this.hourSalary = hourSalary;
	}


	public Date getEntryDate() {
		return entryDate;
	}

	public void setEntryDate(Date entryDate) {
		this.entryDate = entryDate;
	}
	
	private String code;
	private String name;
	private String description;
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	
	private final static String[] gatherProperties = new String[]{"code", "dutyCardNbr"};
	@Override
	public String[] gatherProperties() {
		return gatherProperties;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}


	//	private String workGroupIds;
	private String tel;
	private String email;
	private String mobile;
	private Integer fixedSalary;
	private Integer meritSalary;
	private Integer active;
	private String bankNbr;
	private String deptIds;
	private Integer education;
	private Integer sex;
	private String idCard;
	private String idCardAddress;
	private String address;
	
	private Integer idType;
	private Integer socialType;
	private Integer subsidy;
	private String dutyCardNbr;
	private Integer attribute;
	private BigDecimal hourSalary;
	private Date entryDate;
	
	private BigDecimal exchangeHours;
	private String userId;
	
}
